icon helper: Avoid gratitious pixbuf use
authorMatthias Clasen <mclasen@redhat.com>
Thu, 30 Nov 2017 22:31:17 +0000 (17:31 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Thu, 30 Nov 2017 22:31:17 +0000 (17:31 -0500)
We can just get the texture directly from the icontheme.

gtk/gtkiconhelper.c

index ab42bb9eba4f47812ae47be61c475c687295d961..16b706301c46ff5d69bd5e33b5cfaacd155de81a 100644 (file)
@@ -281,7 +281,6 @@ ensure_texture_for_gicon (GtkIconHelper    *self,
   GtkIconInfo *info;
   GtkIconLookupFlags flags;
   GdkTexture *texture;
-  GdkPixbuf *destination;
 
   icon_theme = gtk_css_icon_theme_value_get_icon_theme
     (gtk_css_style_get_value (style, GTK_CSS_PROPERTY_ICON_THEME));
@@ -293,34 +292,14 @@ ensure_texture_for_gicon (GtkIconHelper    *self,
                                                    gicon,
                                                    MIN (width, height),
                                                    scale, flags);
-  if (info)
-    {
-      *symbolic = gtk_icon_info_is_symbolic (info);
-
-      destination = gtk_icon_info_load_icon (info, NULL);
-    }
-  else
-    {
-      destination = NULL;
-    }
-
-  if (destination == NULL)
-    {
-      GError *error = NULL;
-      destination = gtk_icon_theme_load_icon (icon_theme,
-                                              "image-missing",
-                                              width,
-                                              flags | GTK_ICON_LOOKUP_USE_BUILTIN | GTK_ICON_LOOKUP_GENERIC_FALLBACK,
-                                              &error);
-      /* We include this image as resource, so we always have it available or
-       * the icontheme code is broken */
-      g_assert_no_error (error);
-      g_assert (destination);
-      *symbolic = FALSE;
-    }
-
-  texture = gdk_texture_new_for_pixbuf (destination);
-  g_object_unref (destination);
+  if (info == NULL)
+    info = gtk_icon_theme_lookup_icon (icon_theme,
+                                       "image-missing",
+                                       width,
+                                       flags | GTK_ICON_LOOKUP_USE_BUILTIN | GTK_ICON_LOOKUP_GENERIC_FALLBACK);
+
+  *symbolic = gtk_icon_info_is_symbolic (info);
+  texture = gtk_icon_info_load_texture (info);
 
   return texture;
 }